//---------------------------------------------------------------------
// Author: Keith Hill, jachymko
//
// Description: Abstract base for installer which need to know
//              the installation directory.
//
// Creation Date: Dec 19, 2006
//---------------------------------------------------------------------
using System;
using System.Configuration.Install;

namespace Pscx.Install
{
    public abstract class PscxInstallerBase : Installer
    {
        protected string InstallDir
        {
            get
            {
                string assemblyPath = Context.Parameters["assemblypath"];

                if (string.IsNullOrEmpty(assemblyPath))
                {
                    return null;
                }

                assemblyPath = System.IO.Path.GetDirectoryName(assemblyPath);

                if (assemblyPath.EndsWith("\\"))
                {
                    // Don't want the ending backslash.
                    assemblyPath = assemblyPath.Substring(0, assemblyPath.Length - 1);
                }

                return assemblyPath;
            }
        }
    }
}
